package com.citrinus.feedme;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.TextView;

public class SplashActivity extends Activity {
	@SuppressWarnings("unused")
	private static final String TAG = SplashActivity.class.getSimpleName();

	private static final int SPLASH_DURATION = 1000; // 2 seconds

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_splash);

		setFonts();

		Handler handler = new Handler();
		handler.postDelayed(new Runnable() {
			@Override
			public void run() {
				finish();

				if (!backButtonWasPressed) {
					Intent intent = new Intent(SplashActivity.this, MainActivity.class);
					startActivity(intent);
				}
			}

		}, SPLASH_DURATION);
	}

	private void setFonts() {
		TextView title = (TextView) findViewById(R.id.splash_title);
		TextView subtitle = (TextView) findViewById(R.id.splash_subtitle);

		title.setTypeface(App.getRobot());
		subtitle.setTypeface(App.getRobot());
	}

	private boolean backButtonWasPressed;

	@Override
	public void onBackPressed() {
		backButtonWasPressed = true;
		super.onBackPressed();
	}
}
